﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EntityFramework;
using System.Data;
using BO.Banner;

namespace ProjectQuaDep.Control
{
    public partial class HomeContactBottom : System.Web.UI.UserControl
    {
        int catID = 2;
        string FORMAT_ITEM = "<li><a title=\"{1}\" target=\"_blank\" href=\"{0}\"><img src=\"/Services/CropImages.aspx?width=200&amp;height=80&amp;src={2}\" alt=\"{1}\"></a></li>";
        protected void Page_Load(object sender, EventArgs e)
        {
           // rptList.DataSource = BannersBO.GetTopContact(10);
           // rptList.DataBind();
            DataTable dt = BannerBO.GetListBannerByCatIDBO(catID.ToString());
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string title = BO.Utils.EnCodeString(dt.Rows[i][BO.Const.tbBanners.title].ToString());
                    string url = dt.Rows[i][BO.Const.tbBanners.url].ToString();
                    string img = dt.Rows[i][BO.Const.tbBanners.img].ToString();
                    if ((i+1) % 4 == 1)
                        ltItemDoiTac.Text += "<div>";
                    ltItemDoiTac.Text += string.Format(FORMAT_ITEM,url,title,img);
                    if ((i+1) % 4 == 0)
                        ltItemDoiTac.Text += "</div>";
                }
            }
            else
            {
                this.Visible = false;
            }
        }
    }
}